<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link href="css/style.css" rel="stylesheet" />
	</head>
	<body class="flex_align_center">
		<h1 class='appName defaultColor'>论文帮</h1>
		<div class="appLogoName">论文有问题，就上论文帮</div>
		<script src="js/mui.min.js"></script>
		<script src="js/mui.enterfocus.js"></script>
		<script src="js/app.js"></script>
		<script>
			(function($, doc) {
				$.init({
					statusBarBackground: '#f7f7f7'
				});
				$.plusReady(function() {
					// 获取idfa
					app.getIDFA();
					plus.screen.lockOrientation("portrait-primary");
					var settings = app.getSettings();
					var state = app.getState();
					var welcomePage = plus.webview.getWebviewById("welcome");
					var welcome_loaded_flag = false;
					if(!welcomePage){
						welcomePage = $.preload({
							"id": 'welcome',
							"url": 'welcome.html'
						});
					}else{
						welcome_loaded_flag = true;
					}
					
					welcomePage.addEventListener("loaded",function () {
						welcome_loaded_flag = true;
					});
					//打点
					app.myAjax(businessApiUrl.create,null,{operateType:'pv_ps_启动页'})
					setTimeout(()=>{
						console.log(app.getUserInfo("id"),889)
						if(app.getUserInfo("id")){
							$.openWindow({
								url: 'main.html',
								id: 'main',
								show: {
									aniShow: 'pop-in'
								}
							});
						}else{
							toMain()
						}
					},2000)
					var toMain = function() {
						//使用定时器的原因：
						//可能执行太快，main页面loaded事件尚未触发就执行自定义事件，此时必然会失败
						var id = setInterval(function () {
							if(welcome_loaded_flag){
								clearInterval(id);
								$.fire(welcomePage, 'show', null);
								welcomePage.show("pop-in");
							}
						},20);
					};
					//检查 "登录状态/锁屏状态" 开始
					if (settings.autoLogin && state.token && settings.gestures) {
						$.openWindow({
							url: 'unlock.html',
							id: 'unlock',
							show: {
								aniShow: 'pop-in'
							},
							waiting: {
								autoShow: false
							}
						});
					} else if (settings.autoLogin && state.token) {
						toMain();
					} 
					// close splash 启动页
					//setTimeout(function() {
						//关闭 splash
						plus.navigator.closeSplashscreen();
					//}, 600);
					//检查 "登录状态/锁屏状态" 结束
					var backButtonPress = 0;
					$.back = function(event) {
						backButtonPress++;
						if (backButtonPress > 1) {
							plus.runtime.quit();
						} else {
							plus.nativeUI.toast('再按一次退出应用');
						}
						setTimeout(function() {
							backButtonPress = 0;
						}, 1000);
						return false;
					};
				});
			}(mui, document));
		</script>
	</body>
</html>